package com.capgemini.rdlgae.taglib

class BalanceTagLib {
	def utilisateurService
	
	def getBalance = { attrs ->
		def balance = utilisateurService.getBalance(attrs['utilisateur'])

		if(balance < 0.0){
			
			def nbTicketRestaurant = Math.round(Math.ceil(Math.abs(balance) / 8.0))

			
			out << "<span style='color:red'>"+balance.toString()+" € </span> soit "+nbTicketRestaurant +" ticket"+ ((nbTicketRestaurant != 1)? "s":"") +" restaurant"
		}
		else
		out << "<span style='color:green'>"+balance.toString()+" €</span>"
	}
	
}
